#include<iostream>
#include<map>
using namespace std;
const int N = 2e5 + 10;
typedef long long LL;
LL arr[N];
LL c;
int n;
map<LL, int>mp;
int main()
{
	cin >> n >> c;
	for (int i = 0; i < n; i++) {
		scanf_s("%lld", &arr[i]);
		mp[arr[i] + c]++;
	}
	LL ans = 0;
	for (int i = 0; i < n; i++) {
		if (mp[arr[i]]) {
			ans += mp[arr[i]];
		}
	}
	cout << ans << endl;
	return 0;
}